home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
blankery
/
blanker
/
source
/
blankers
/
clock
/
prefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-25
|
4KB
|
157 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include <graphics/text.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/asl_protos.h>
#include "Clock.h"
#include "Clock_rev.h"
#include "/defs.h"
struct cPrefObject {
UBYTE fName[64], Speed, Cycle, Secs, Military;
struct TextAttr Font;
};
VOID blank( VOID );
struct cPrefObject nP;
STATIC const UBYTE VersTag[] = VERSTAG;
extern struct Task **Task;
extern ULONG Depth, Mode;
extern UBYTE *prefData;
VOID setClockPrefs( VOID )
{
GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, nP.Speed, 0L );
GT_SetGadgetAttrs( ClockGadgets[GD_FTXT], ClockWnd, 0L, GTTX_Text, nP.fName, 0L );
GT_SetGadgetAttrs( ClockGadgets[GD_FSIZE], ClockWnd, 0L, GTNM_Number, nP.Font.ta_YSize, 0L );
GT_SetGadgetAttrs( ClockGadgets[GD_MIL], ClockWnd, 0L, GTCY_Active, nP.Military, 0L );
GT_SetGadgetAttrs( ClockGadgets[GD_CYCLE], ClockWnd, 0L, GTCY_Active, nP.Cycle, 0L );
GT_SetGadgetAttrs( ClockGadgets[GD_SECS], ClockWnd, 0L, GTCY_Active, nP.Secs, 0L );
}
int OKClicked( VOID )
{
CopyMem( &nP, prefData, sizeof( struct cPrefObject ));
return( QUIT );
}
int TESTClicked( VOID )
{
*Task = FindTask( 0L );
blank();
return( CONTINUE );
}
int CANCELClicked( VOID )
{
return( QUIT );
}
int SPEEDClicked( VOID )
{
nP.Speed = ClockMsg.Code;
return( CONTINUE );
}
int MILClicked( VOID )
{
nP.Military = ClockMsg.Code;
return( CONTINUE );
}
int CYCLEClicked( VOID )
{
nP.Cycle = ClockMsg.Code;
return( CONTINUE );
}
int SECSClicked( VOID )
{
nP.Secs = ClockMsg.Code;
return( CONTINUE );
}
int FONTClicked( VOID )
{
struct FontRequester *fReq;
if( fReq = ( struct FontRequester * )AllocAslRequestTags( ASL_FontRequest, ASL_FontName, (ULONG)nP.fName,
ASL_FontHeight, nP.Font.ta_YSize, ASL_MaxHeight, 100, TAG_DONE )) {
if( AslRequestTags( fReq, ASLFO_Window, ClockWnd, ASLFO_SleepWindow, TRUE, ASLFO_TitleText,
(ULONG)"Please choose a font...", 0L )) {
CopyMem( fReq->fo_Attr.ta_Name, nP.fName, 31 );
nP.Font.ta_YSize = fReq->fo_Attr.ta_YSize;
}
FreeAslRequest( fReq );
}
setClockPrefs();
return( CONTINUE );
}
int ClockVanillaKey( VOID )
{
switch( ClockMsg.Code ) {
case 'o':
return( OKClicked() );
case 't':
return( TESTClicked() );
case 'c':
return( CANCELClicked() );
case 'f':
return( FONTClicked());
case 's':
GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, ++(nP.Speed) > 50 ?
nP.Speed = 50 : nP.Speed, 0L );
return( CONTINUE );
case 'S':
GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, --(nP.Speed) < 1 ?
nP.Speed = 1 : nP.Speed, 0L );
return( CONTINUE );
default:
return( CONTINUE );
}
}
VOID prefs( LONG command )
{
switch( command ) {
case STARTUP:
if( !ClockWnd ) {
CopyMem( prefData, &nP, sizeof( struct cPrefObject ));
nP.Font.ta_Name = nP.fName;
if( !SetupScreen() ) {
if( !OpenClockWindow()) setClockPrefs();
CloseDownScreen();
}
} else {
ActivateWindow( ClockWnd );
WindowToFront( ClockWnd );
}
break;
case IDCMP:
if( HandleClockIDCMP() != QUIT ) break;
case KILL:
CloseClockWindow();
break;
}
}
LONG winSig( VOID )
{
return( ClockWnd ? ( 1L << ClockWnd->UserPort->mp_SigBit ) : 0L );
}